package atlantik.game;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

public class EstateGroup extends AtlantikIdHolder<Integer, EstateGroup> implements
		Iterable<Estate> {

	private String name;

	private SortedSet<Estate> estates = new TreeSet<Estate>();

	public EstateGroup(Atlantik client) {
		super(client);
	}

	public String getName() {
		return name;
	}

	void setName(String name) {
		this.name = name;
	}

	void add(Estate estate) {
		if (estate != null && !estates.contains(estate))
			estates.add(estate);
	}

	public Iterator<Estate> iterator() {
		return new ArrayList<Estate>(estates).iterator();
	}

	public boolean isFullyOwnedBy(Player player) {
		return player.estates.contains(estates);
	}

}
